package com.lavender.extention._common_api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * <p>
 * Environment Api的区别
 * </p>
 * @author: zhu.chen
 * @date: 2021/3/24
 * @version: v1.0.0
 */
@Component
public class EnvironmentTest implements CommandLineRunner {

    @Autowired
    private Environment environment;

    @Override
    public void run(String... args) throws Exception {
        System.out.println(environment.getProperty("name"));
        /**
         * environment#resolvePlaceholders能赋默认值，跟@Value("${name:xiaohong}")差不多
         */
        System.out.println(environment.resolvePlaceholders("${name:xiaohong}"));
    }

}
